<title>new smiles</title>
<div class="layui-card layadmin-header">
<div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">主页</a>
    <a><cite>应用</cite></a>
    <a><cite>新的文章</cite></a>
</div>
</div>
<div class="layui-fluid">
    <div class="layui-form" lay-filter="change-smiles">
        <div class="layui-form-item">
            <textarea name="content" required lay-verify="required" placeholder="我很愿意遇见你" class="layui-textarea"></textarea>
        </div>
        <div class="layui-form-item">
            <div style="margin-left: -1px;" class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="push">发布</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['admin','server','form','laytpl'],function(){
        var admin = layui.admin;
        var userInfo = admin.getUserInfo();
        var server = layui.server;
        var form = layui.form;
        var smiles = layui.sessionData('changeTable').changeSmile;
        layui.sessionData('changeTable',{
            key:'changeSmile',
            remove:true
        });
        form.val('change-smiles',smiles)
        form.on('submit(push)',function(data){
            var options = {};
            if(smiles){
                options.url = 'changeSmile';
            }else{
                options.url = 'addSmile';
            }
            var id = null;
            if(smiles){
                id = smiles.id;
            }
            options.data = {
                id:id,
                content:data.field.content,
                name:userInfo.name,
            }
            options.callback = function(data){
                layer.msg('发布成功');
                setTimeout(() => {
                    location.reload();
                }, 1000);
            }
            server.req(options);
        });
    });
</script>